package com.learn.mqq.service;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息生产者service类
 * @Author guowenhao
 * @Date 2023/12/4 16:34
 * @PackageName:com.learn.mqq
 * @ClassName: ProducerService
 * @Description: TODO
 * @Version 1.0
 */
@Component("producerService")
public class ProducerService {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    /**
     * mq发送信息
     * @param msg
     */
    public void sendMessage(String msg) {
        System.out.println("发送消息内容："+msg);
        rocketMQTemplate.convertAndSend("rocketmq-msg", msg);
    }
}
